package com.example.wechatdaka.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.wechatdaka.entity.User;
import com.example.wechatdaka.entity.UserTeacher;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lx
 * @since 2020-11-27
 */
public interface UserTeacherMapper extends BaseMapper<UserTeacher> {
    @Select("select a.id,a.lxUserId,b.lxUserNumber,b.lxUsername,b.lxUserSex,b.lxUserPhone,b.lxUserEmail,a.lxPositionalTitles,a.lxDegree from lx_user_teacher a,lx_user b where a.lxUserId=b.id")
    List<UserTeacher> queryAllTeacher();
    @Select("select id as lxUserId,lxUserNumber,lxUsername,lxUserSex,lxUserPhone from lx_user where id not in(select lxUserId from  lx_user_teacher) and lxRoleId=2")
    List<User> selectAddTeacher();
    @Select("select a.id,a.lxUserId,b.lxUserNumber,b.lxUsername,b.lxUserSex,b.lxUserPhone,b.lxUserEmail,a.lxPositionalTitles,a.lxDegree from lx_user_teacher a,lx_user b where a.lxUserId=b.id")
    public IPage<UserTeacher> queryAllTeacherPage(Page page);
    @Select("select a.id,a.lxUserId,b.lxUserNumber,b.lxUsername,b.lxUserSex,b.lxUserPhone,b.lxUserEmail,a.lxPositionalTitles,a.lxDegree \n" +
            "from lx_user_teacher a,lx_user b where a.lxUserId=b.id and b.lxUserNumber=#{id}")
    public UserTeacher queryByNumber(String id);
    @Select("select a.id,a.lxUserId,b.lxUserNumber,b.lxUsername,b.lxUserSex,b.lxUserPhone,b.lxUserEmail,a.lxPositionalTitles,a.lxDegree \n" +
            "from lx_user_teacher a,lx_user b where a.lxUserId=b.id and b.lxUsername LIKE concat('%',#{keyword},'%')")
    public IPage<UserTeacher> queryByKeywordPage(Page page,String keyword);
}
